/*
 * @lc app=leetcode.cn id=401 lang=javascript
 *
 * [401] 二进制手表
 */

// @lc code=start
/**
 * @param {number} turnedOn
 * @return {string[]}
 */
var readBinaryWatch = function(turnedOn) {
    let resultArr = []
    for (let hour = 0; hour < 12; hour++) {
        for (let minute = 0; minute < 60; minute++) {
            if (
                ( parseInt(hour).toString(2).split('').filter(e => e === '1').length
                +
                parseInt(minute).toString(2).split('').filter(e => e === '1').length )
                ===
                turnedOn
            ) {
                if ((minute + '').length === 1) {
                    minute = '0' + minute
                }
                resultArr.push(hour + ':' + minute)
            }
        }
    }
    return resultArr
};
// @lc code=end

/* 
    应该用溯源法求解，但是这里不会，看暴力解法容易些，就用暴力求解算了
*/